import Vue from "vue";
import VueRouter from "vue-router";

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "index",
    component: () => import("../views/index.vue"),
    children:[
      {
        path:'',
        redirect:'/home'
      },
      {
        path: "/home",
        name: "home",
        component: () => import("../views/home/index.vue"),
      },
      {
        path: "/car",
        name: "car",
        component: () => import("../views/home/index.vue"),
      },
      {
        path: "/order",
        name: "order",
        component: () => import("../views/home/index.vue"),
      },
      {
        path: "/finance",
        name: "finance",
        component: () => import("../views/home/index.vue"),
      },
    ]
  },
// 车辆
  // 车辆详情
  {
    path: "/Cpqd",
    name: "Cpqd",
    component: () => import("@/views/Cpqd.vue"),
  },
  {
    path: "/Fwbz",
    name: "Fwbz",
    component: () => import("@/views/Fwbz.vue"),
  },
  {
    path: "/Ppjs",
    name: "Ppjs",
    component: () => import("@/views/Ppjs.vue"),
  },
  {
    path: "/Scqj",
    name: "Scqj",
    component: () => import("@/views/Scqj.vue"),
  },
  {
    path: "/Tzyl",
    name: "Tzyl",
    component: () => import("@/views/Tzyl.vue"),
  },
  {
    path: "/Xmys",
    name: "Xmys",
    component: () => import("@/views/Xmys.vue"),
  }

];

const router = new VueRouter({
  mode: "history",
  // mode: "hash",
  base: process.env.BASE_URL,
  routes,
});

export default router;
